package com.qf.web.servlet;


import com.alibaba.fastjson.JSON;
import com.qf.domain.GoodsType;
import com.qf.service.GoodsService;
import com.qf.service.impl.GoodsServiceImpl;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

//商品列表
@WebServlet(value = "/goodstypeservlet")
public class GoodsTypeServlet extends BaseServlet {
    //上部商品显示
    public String goodstypelist(HttpServletRequest request, HttpServletResponse response) throws IOException {

        //我要获得商品列表的所有信息  查询商品列表的名称 返回的是整个字符串然后传过去
//        typeId
        //声明为json数据
        response.setContentType("application/json;charset=utf-8");
        GoodsService goodsService=new GoodsServiceImpl();
        List<GoodsType> goodsTypes=goodsService.find(1);
        System.out.println(goodsTypes.get(1));
        String s = JSON.toJSONString(goodsTypes);
        response.getWriter().write(s);
        return null;
    }
}
